<?php
/**
 * Date: 10/22/12
 * Time: 8:59 PM
 * User: Amitav Roy
 */
class Dashboard extends CI_Controller{
	function __construct() {
		parent::__construct();

		// This is restricted area.
		auth_user();

		// Loading the dashboard model.
		$this->load->model('dashboard_m','dash_model');
	}

	function index() {
		// Redirecting user to home.
		redirect('dashboard/home');
	}

	function home() {
		$data['pagetitle'] = 'Dashboard';
		$data['subheading'] = 'Welcome to your dashboard';
		$data['scripts']['transaction'] = 'transaction';
		$data['scripts']['dashboard'] = 'dashboard';
		$data['viewname'] = 'dashboard_v.php';
		$data['viewdata']['last_ten_trans'] = $this->dash_model->last_ten_transaction();
		$data['viewdata']['category_trend'] = $this->dash_model->category_trend();

		$this->load->view('master', $data);
	}

	/** These pages are just for getting data in JSON format. */
	function json_last_ten_trans() {
		$result = $this->dash_model->last_ten_transaction();
		print json_encode($result);
	}
	
	/**
	 * This function will return the bill payments that are made.
	 * TODO: Need to also show the bills which are due this month 
	 * and show their individual status 
	 */
	public function bills_payments_this_month() {
		$result = $this->dash_model->bills_payments_this_month();
		print json_encode($result);
	}
}

/* End of file dashboard.php */
/* Location: ./application/controllers/dashboard.php */